import request from '@/utils/request'
import type { WithdrawalRequest, WithdrawalQuery, PaginationResponse } from '@/types'

// 获取提现申请列表
export const getWithdrawalRequests = (params: WithdrawalQuery): Promise<PaginationResponse<WithdrawalRequest>> => {
  return request.get('/finance/withdrawals', { params })
}

// 审核提现申请
export const reviewWithdrawal = (id: number, data: { status: 'approved' | 'rejected'; remark?: string }): Promise<void> => {
  return request.put(`/finance/withdrawals/${id}/review`, data)
}

// 批量审核提现申请
export const batchReviewWithdrawals = (ids: number[], status: 'approved' | 'rejected', remark?: string): Promise<void> => {
  return request.post('/finance/withdrawals/batch-review', { ids, status, remark })
}

// 获取收益统计
export const getRevenueStats = (): Promise<any> => {
  return request.get('/finance/revenue')
}

// 获取财务报表
export const getFinanceReports = (params: any): Promise<any> => {
  return request.get('/finance/reports', { params })
}

// 获取资金流水
export const getTransactions = (params: any): Promise<any> => {
  return request.get('/finance/transactions', { params })
}

// 导出财务数据
export const exportFinanceData = (params: any): Promise<Blob> => {
  return request.get('/finance/export', { 
    params,
    responseType: 'blob'
  })
}